package program.utils;

import program.domain.PCB;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @program: OSAlgorithms
 * @description: 输入工具类
 * @author: W
 * @create: 2021-10-29 19:55
 **/
public class InputUtil {

    public ArrayList<PCB> create() {
        //创建的进程数目
        int num = 0;

        ArrayList<PCB> processes = new ArrayList<>();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入进程个数：");
        num = scanner.nextInt();

        //输入进程信息
        for (int i = 0; i < num; i++) {
            System.out.println("请输入第" + (i + 1) + "个进程标识符:");
            String pid = scanner.nextLine();
            System.out.println("请输入第" + (i + 1) + "个进程到达时刻:");
            Integer arriveTime = scanner.nextInt();
            System.out.println("请输入第" + (i + 1) + "个进程所需时间:");
            Integer cpuTime = scanner.nextInt();
            PCB process = new PCB(pid ,arriveTime,cpuTime, "创建");
            System.out.println("进程 " + (i + 1) + "创建完成 :" + "PID:" + process.getPid());
            processes.add(process);
        }
        return processes;
    }

}
